import os
from typing import Dict, Optional
from pydantic_settings import BaseSettings

class ModelConfig(BaseSettings):
    """Model configuration
    https://deepinfra.com/hexgrad/Kokoro-82M
    
    """
    # Chat model settings
    CHAT_MODEL_PATH: str = "/models/Qwen/Qwen2.5-7B-Instruct"
    
    # Embedding model settings
    EMBEDDING_MODEL_PATH: str = "/models/maidalun1020/bce-embedding-base_v1"
    
    # TTS model settings
    TTS_MODEL_PATH: str = "/models/microsoft/speecht5_tts"
    TTS_VOCODER_PATH: str = "/models/microsoft/speecht5_hifigan"

    # TTS model settings
    KOKORO_MODEL_PATH: str = "/models/hexgrad/Kokoro-82M"
    
    # TTS embeddings dataset settings
    EMBEDDINGS_DATASET_NAME: str = "Matthijs/cmu-arctic-xvectors"
    
    # Server settings
    HOST: str = "0.0.0.0"
    PORT: int = 9000
    
    # Voice mappings for TTS
    VOICE_MAPPINGS: Dict[str, Dict[str, str]] = {
        "speecht5": {
            "default": "0",
            "ash": "0",      # bdl (male)
            "ballad": "1",   # clb (female)
            "coral": "2",    # jmk (male)
            "sage": "3",     # ksp (male)
            "verse": "4",    # rms (male)
            # 兼容旧版本
            "alloy": "0",
            "echo": "1",
            "fable": "2",
            "onyx": "3",
            "nova": "4",
            "shimmer": "5"
        },


# CHOICES = {
# '🇺🇸 🚺 Heart ❤️': 'af_heart',
# '🇺🇸 🚺 Bella 🔥': 'af_bella',
# '🇺🇸 🚺 Nicole 🎧': 'af_nicole',
# '🇺🇸 🚺 Aoede': 'af_aoede',
# '🇺🇸 🚺 Kore': 'af_kore',
# '🇺🇸 🚺 Sarah': 'af_sarah',
# '🇺🇸 🚺 Nova': 'af_nova',
# '🇺🇸 🚺 Sky': 'af_sky',
# '🇺🇸 🚺 Alloy': 'af_alloy',
# '🇺🇸 🚺 Jessica': 'af_jessica',
# '🇺🇸 🚺 River': 'af_river',
# '🇺🇸 🚹 Michael': 'am_michael',
# '🇺🇸 🚹 Fenrir': 'am_fenrir',
# '🇺🇸 🚹 Puck': 'am_puck',
# '🇺🇸 🚹 Echo': 'am_echo',
# '🇺🇸 🚹 Eric': 'am_eric',
# '🇺🇸 🚹 Liam': 'am_liam',
# '🇺🇸 🚹 Onyx': 'am_onyx',
# '🇺🇸 🚹 Santa': 'am_santa',
# '🇺🇸 🚹 Adam': 'am_adam',
# '🇬🇧 🚺 Emma': 'bf_emma',
# '🇬🇧 🚺 Isabella': 'bf_isabella',
# '🇬🇧 🚺 Alice': 'bf_alice',
# '🇬🇧 🚺 Lily': 'bf_lily',
# '🇬🇧 🚹 George': 'bm_george',
# '🇬🇧 🚹 Fable': 'bm_fable',
# '🇬🇧 🚹 Lewis': 'bm_lewis',
# '🇬🇧 🚹 Daniel': 'bm_daniel',
# '🇬🇧 🚺xiaobei': 'zf_xiaobei',
# '🇬🇧 🚺xiaobei': 'zf_xiaoni',
# '🇬🇧 🚺xiaobei': 'zf_xiaoxiao',
# '🇬🇧 🚺xiaobei': 'zf_xiaoyi',
# '🇬🇧 🚹zm_yunjian': 'zm_yunjian',
# '🇬🇧 🚹zm_yunxi': 'zm_yunxi',
# '🇬🇧 🚺zm_yunxia': 'zm_yunxia',
# '🇬🇧 🚹zm_yunxi': 'zm_yunyang',
# }

        "kokoro": {
            "default": "am_liam",
            # 兼容旧版本
            "alloy": "am_liam",
            "echo": "am_echo",
            "ash": "am_michael",
            "coral":"af_aoede",
            "fable": "am_eric",
            "onyx": "am_onyx",
            "nova": "af_jessica",
            "shimmer": "bf_alice",
            "sage": "bf_lily",
            "af_heart":"af_heart",
            "af_alloy": "af_alloy",
            "af_aoede": "af_aoede",
            "af_bella":"af_bella",
            "af_jessica":"af_jessica",
            "af_kore":"af_kore",
            "af_nicole": "af_nicole",
            "af_nova":"af_nova",
            "af_river":"af_river",
            "af_sarah":"af_sarah",
            "af_sky":"af_sky",
            "am_adam":"am_adam",
            "am_echo":"am_echo",
            "am_eric":"am_eric",
            "am_fenrir":"am_fenrir",
            "am_liam":"am_liam",
            "am_michael":"am_michael",
            "am_onyx":"am_onyx",
            "am_puck":"am_puck",
            "am_santa":"am_santa"
        },

        "kokoro_zh": {
            "default": "zm_yunjian",
            # 兼容旧版本
            "alloy": "zm_yunjian",
            "echo": "zm_yunxi",
            "ash": "zm_yunyang",
            "coral":"zf_xiaobei",
            "fable": "zm_yunjian",
            "onyx": "zm_yunxia",
            "nova": "zm_yunxi",
            "shimmer": "zf_xiaoxiao",
            "sage": "zf_xiaoyi",
            "zf_xiaobei": "zf_xiaobei",
            "zf_xiaoni": "zf_xiaoni",
            "zf_xiaoxiao": "zf_xiaoxiao",
            "zf_xiaoyi": "zf_xiaoyi",
            "zm_yunjian": "zm_yunjian",
            "zm_yunxi": "zm_yunxi",
            "zm_yunxia": "zm_yunxia",
            "zm_yunyang": "zm_yunyang"
        }
    }
    
    class Config:
        env_prefix = "LLM_"  # 环境变量前缀

# 创建全局配置实例
config = ModelConfig() 